using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;

using WL.Think.Abp.Localization;

namespace WL.Think.Sample.Permissions;

public class BackPermissionDefinitionProvider : PermissionDefinitionProvider
{
    public override void Define(IPermissionDefinitionContext context)
    {
        var myGroup = context.AddGroup(BackPermissions.GroupName, L("Sample"));
        var booksPermission = myGroup.AddPermission(BackPermissions.Books.Default, L("Permission:Books"), MultiTenancySides.Both);
        booksPermission.AddChild(BackPermissions.Books.Create, L(ThinkResourceNames.Create),MultiTenancySides.Both);
        booksPermission.AddChild(BackPermissions.Books.Edit, L(ThinkResourceNames.Edit),MultiTenancySides.Both);
        booksPermission.AddChild(BackPermissions.Books.Delete, L(ThinkResourceNames.Delete),MultiTenancySides.Both);
    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<ThinkResource>(name);
    }
}
